<?php

/**
 * 去掉千分位数据后面多余的0
 */
if (!function_exists('num_format')) {
    function num_format($number, $decimals = 6)
    {
        if (empty($number)) return 0;
        $numberExp = explode('.', $number);
        $numberStart = $numberExp[0];
        $numberEnd = isset($numberExp[1]) ? $numberExp[1] : 0;
        $numberEnd = substr($numberEnd, 0, $decimals);
        if ($numberEnd > 0) {
            $number = $numberStart . '.' . rtrim($numberEnd, '0');
        } else {
            $number = $numberStart . trim($numberEnd, '0');
        }
        return $number;
    }
}

/*if (!function_exists('qw_text_msg_send')) {
    function qw_text_msg_send($appId, $appSecret, $content, $toUser)
    {
        $qwService = new \App\Services\QyapiService($appSecret, $appId);
        $accessToken = $qwService->getAccessToken();
        $url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' . $accessToken;
        if (is_array($toUser)) {
            $users = join('|', $toUser);
        } else {
            $users = $toUser;
        }
        $post = [
            'touser' => $users,
            'agentid' => $appId,
            'msgtype' => 'text',
            'text' => [
                'content' => $content
            ],
            'enable_duplicate_check' => 1
        ];
        $res = \App\Utils\HttpUtil::httpPost($url, json_encode($post));
    }
}*/
